<!--
 * @Author: 卡卡 1071780426@qq.com
 * @Date: 2023-09-27 17:43:02
 * @LastEditors: 卡卡 1071780426@qq.com
 * @LastEditTime: 2023-10-07 15:56:29
 * @FilePath: \mould\src\App.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div id="app">

    <router-view v-if="isRouterAlive"></router-view>
  </div>
</template>
<script>
export default {
  name: 'App',
  provide() {
    return {
      reload: this.reload
    }
  },
  data() {
    return {
      isRouterAlive: true
    }
  },

  mounted() {
    window.addEventListener('offline', () => {
      // 网络由正常常到异常时触发
      sessionStorage.locationUrl = window.location.href;
      this.$router.replace('/networkError')
    });
    window.addEventListener('online', () => {
      window.location.href = sessionStorage.locationUrl
    });
  },

  methods: {
    reload() {
      this.isRouterAlive = false
      this.$nextTick(function () {
        this.isRouterAlive = true
      })
    }
  },
  components: {
  }
}
</script>
<style></style>
